<!--#include file="Config.asp" -->
<!--#include file="HeadTop.asp" -->
<%

type_id=int(Request("type_id"))
type_fatherID=int(Request("type_fatherID"))
ActionType=request("ActionType")
SaveType=request("SaveType")

'Add
if ActionType="Add" or ActionType="" then
AName="确定增加"
URL="?SaveType=AddOK"
end if

'Mod
if ActionType="Mod" and type_id<>0 then
AName="确定修改"
sql="select * from Plan_URLCLass where type_ID="&type_ID
rs.open sql,conn,1,1
type_name=trim(rs("type_name"))
type_FatherID=int(rs("type_FatherID"))
content=trim(rs("content"))
rs.close
AID=type_ID
URL="?SaveType=ModOK&type_ID="&type_ID
end if

'SaveAddNew
If SaveType="AddOK" And Trim(Request("type_name"))<>"" then
sql= "SELECT * from Plan_URLCLass WHERE (type_id is null)"
rs.open sql,conn,1,3
rs.addnew
rs("type_name") =Trim(Request("type_name"))
rs("type_fatherID") =Int(Request("type_fatherID"))
rs("content") =Trim(Request("comment"))
rs("userid") =session("AnyPIM_userID")
rs.Update
rs.close
End If

'SaveModNew
If SaveType="ModOK" And Trim(Request("type_name"))<>"" then
sql= "SELECT * from Plan_URLCLass WHERE userid="&session("AnyPIM_userID")&" and type_id="&type_ID
rs.open sql,conn,1,3
rs("type_name") =Trim(Request("type_name"))
rs("type_fatherID") =Int(Request("type_fatherID"))
rs("content") =Trim(Request("comment"))
rs("userid") =session("AnyPIM_userID")
rs.Update
rs.close
End If


'Del
if SaveType="Del" and type_ID<>0 then
sql="delete from Plan_URLCLass where userid="&session("AnyPIM_userID")&" and type_ID="&type_ID
conn.execute(sql)
end If
%>
<table class="table table-condensed table-striped">
<form method="post" action="?" name="addform">
<tr bgcolor="#ddeeff">
<td>
<select name="type_fatherID">
<option value="0" <%If type_FatherID=0 then%>selected<%End if%>>0.顶级分类</option>
<%
sql="select * from Plan_URLCLass where userid="&session("AnyPIM_userID")&" and type_fatherID=0 order by type_ID"
Rs.open sql,conn,1,1
for m=1 to rs.recordcount
%>
<option value="<%=int(Rs("type_ID"))%>" <%If type_FatherID=int(rs("type_ID")) then%>selected<%End if%>><%=rs("type_ID")%>.<%=Trim(rs("type_name"))%></option>
<%
rs.moveNext
Next
rs.close
%>
</select>
名称：
<input type="text" name="type_name"  value="<%=type_name%>" size='30'>
内容：
<input type="text" name="Comment" value="<%=content%>" size='30'>
<input type="submit" name="Submit" value="<%=AName%>">
<A HREF="?ActionType=Add">[<U><FONT COLOR="#FF0000"><B>增加</B></FONT></U>]</A>
</td>
</tr>
</form>
</table>
<%
sql="select * from Plan_URLCLass where userid="&session("AnyPIM_userID")&" and type_fatherID=0 order by type_id"
rs.open sql,conn,1,1

%>
<!-- 列表 -->
<table class="table table-condensed table-striped table-bordered">
<tr class="success">
<TD>Edit</TD>
<TD>type_id</TD>
<TD>type_name</TD>
<TD>type_fatherID</TD>
<TD>content</TD>
<TD>数量/Del</TD>
</TR>
<%
for r=1 to rs.recordcount
%>
<!-- Name -->
<tr <%If int(rs("type_fatherID"))=0 then%>class="danger"<%End if%>>
<td><A HREF="?type_id=<%=int(rs("type_id"))%>&ActionType=Mod">Edit</A></td>
<td><%=int(rs("type_id"))%></td>
<td><%=Trim(rs("type_name"))%></td>
<td><%=int(rs("type_fatherID"))%></td>
<td><%=Trim(rs("content"))%></td>
<td>&nbsp;</td>
</tr>
<%
set rson=server.createobject("adodb.recordset")
rsonsql="select * from Plan_URLCLass where userid="&session("AnyPIM_userID")&" and type_fatherID="&Int(rs("type_id"))&" order by type_id"
rson.open rsonsql,conn,1,1
for dd=1 to rson.recordcount

url_type_id=int(rson("type_id"))
'统计classid类的图书数量
set rs2=server.createobject("adodb.recordset")
rs2.open "select classid from plan_URL where userid="&session("AnyPIM_userID")&" and classid="&url_type_id&" ",Conn,1,1
url_type_count=rs2.recordcount
rs2.close
%>
<tr >
<td><A HREF="?type_id=<%=url_type_id%>&ActionType=Mod">Edit</A></td>
<td><%=url_type_id%></td>
<td><%=Trim(rson("type_name"))%></td>
<td><%=int(rson("type_fatherID"))%></td>
<td><%=Trim(rson("content"))%></td>
<td>
<a href="UrlAdmin.asp?classid=<%=url_type_id%>"><%=url_type_count%></a>&nbsp;
<%If url_type_count=0 then%>
<a href="?type_id=<%=url_type_id%>&SaveType=Del">Del</a>
<%End if%>
</td>
</tr>
<%
rson.moveNext
Next
rson.close
%>
</TD>
</tr>
<%
rs.moveNext
Next
%>
</TABLE>
<%
rs.close
set conn=nothing
%>
<!-- #include file="Foot.asp" -->
